package com.zyz.J_枚举;

/**
 * @author: vick
 * @Date: 2025/3/27
 * @Description:
 * @version: 1.0
 */
public class ParkStatusTest {
    public static void main(String[] args) {
        ParkStatusEnum appearance = ParkStatusEnum.APPEARANCE;
        System.out.println(appearance);
        System.out.println(ParkStatusEnum.APPEARANCE.getCode());
        System.out.println(ParkStatusEnum.APPEARANCE.getDesc());

        System.out.println("========");
        //TODO values()：返回枚举类型的对象数组。
        ParkStatusEnum[] values = ParkStatusEnum.values();
        for (ParkStatusEnum parkStatusEnum : values) {
            System.out.println(parkStatusEnum + "，code: " +  parkStatusEnum.getCode() + "，desc: "+ parkStatusEnum.getDesc());
        }

        System.out.println("========");
        //TODO valueOf(String str) 可以把一个字符串转为对应的枚举类对象
        // 如果没有 对应的枚举对象，就会抛出异常  IllegalArgumentException
        ParkStatusEnum parkStatusEnum = ParkStatusEnum.valueOf("APPEARANCE");
        //ParkStatusEnum parkStatusEnum = ParkStatusEnum.valueOf("112321321321");
        System.out.println(parkStatusEnum);

        System.out.println("======");
        String description = ParkStatusEnum.getDescription(1);
        System.out.println(description);
        String description2 = ParkStatusEnum.getDescription(11111);
        System.out.println(description2);
    }
}
